//
// Created by EDY on 24-11-3.
//

#ifndef MYCONTACT_H
#define MYCONTACT_H

#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
#include "MysqlManager.h"
#include <time.h>
#include <iomanip>

using namespace std;

const string adminUserName = "admin";
const string  adminPassword = "admin";
const int MAX_SIZE = 20;
const int CHECKNUM_LENGTH = 4;

void inputSelectNumber(int x);
void clearKey();
void pressEnterToContinue();
void inputSelectError();
void DisableEcho(HANDLE hStdin);
void EnableEcho(HANDLE hStdin);
string inputPasswrod();
string generateRandomString(int length);


class MyContact {
private:
    MyContact(){};
    static MyContact* instance;

public:
    static MyContact* getInstance() {
        return instance;
    }

    map<string, Friend> contacts;
    static bool dirtyFlag;
    MysqlManager mysql;

    void loginMenu();
    void login();
    void managerLogin();
    void managerLoginSuccess();
    void managerLoginMenu();

    void addFriend();
    void dealeteFriend();
    void searchFriend () const;
    void updateFriend();
    void saveContact();
    void loadContact();
    void showFriends();
};



#endif //MYCONTACT_H
